<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>

    <title>AdminLTE 3 | 编辑游客</title>
    <!-- Tell the browser to be responsive to screen width -->
    <jsp:include page="../include/header.jsp"></jsp:include>
    <!-- Google Font: Source Sans Pro -->
    <%--<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">--%>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Navbar -->
    <jsp:include page="../include/nav.jsp"/>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <jsp:include page="../include/aside.jsp"/>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>游客编辑</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">DataTables</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">订单：${order.id}</h3>
                                <h1></h1>
                                <button type="button" onclick="toAdd()" class="btn btn-block btn-success btn-sm-2">游客编辑</button>

                            </div>
                            <!-- /.card-header -->
                            <div class="card-body">
                                <table id="example2" class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>id</th>
                                        <th>游客姓名</th>
                                        <th>游客性别</th>
                                        <th>身份证</th>
                                        <th>游客电话</th>
                                        <th>游客生日</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="tdata">

                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <th>id</th>
                                        <th>游客姓名</th>
                                        <th>游客性别</th>
                                        <th>身份证</th>
                                        <th>游客电话</th>
                                        <th>游客生日</th>
                                        <th>操作</th>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->


                        <!-- /.card -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->


    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<div style="display: none">
    <div class="form-group col-md-6 courarea" >
        <label>游客</label>
        <select id="sele"  class="form-control select2" style="width: 100%;">
        </select>
    </div>
</div>


<jsp:include page="../include/footer.jsp"/>
<!-- page script -->
<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../../plugins/daterangepicker/daterangepicker.js"></script>
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- DataTables -->
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<!-- AdminLTE App -->
<script src="../../js/adminlte.min.js"></script>
<script src="../../js/layer/layer.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../js/demo.js"></script>


<script>
    $(function () {
        load();
        $("#example1").DataTable({
            "responsive": true,
            "autoWidth": false,
        });
        $('#example2').DataTable({
            "paging": false,
            "lengthChange": false,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
    });
    function jump(page) {
        var keywords =$("[name='keywords']").val();
        location.href="/tourist/list?page="+page+"&keywords="+keywords;
    }
    var orderid ='${order.id}';
    //添加
    function toAdd() {
        $.ajax({
            url:"/order/getTouristOut",
            type:"post",
            data:{orderid:orderid},
            success:function (data) {
                var html='';
                for (var i=0;i<data.length ;i++){
                    html +="<option value='"+data[i].id+"'>"+data[i].touristName+"</option>";
                }
                $("#sele").html(html);
                //页面层
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['420px', '240px'], //宽高
                    content: $(".courarea").html(),
                    btn:"提交",
                    yes:function () {
                        var tourist_id=$(".select2")[1].value;
                        $.ajax({
                            url:"/order/addTourist",
                            type:"post",
                            data:{orderid:orderid,touristid:tourist_id},
                            success:function (data) {
                              location.reload();
                            }
                        });
                    }

                });
            }
        });
    }

    function load() {
        $.ajax({
            url:"/order/getTourist",
            type:"post",
            data:{orderid:orderid},
            success:function (data) {
                var html='';
                for (var i=0;i<data.length ;i++){
                    html +="<tr>";
                    html +="  <td>"+data[i].id+"</td>";
                    html +="  <td>"+data[i].touristName+"</td>";
                    html +="  <td>"+data[i].touristSex+"</td>";
                    html +="  <td>"+data[i].touristIdcard+"</td>";
                    html +="  <td>"+data[i].touristPhone+"</td>";
                    html +="  <td>"+data[i].touristBrithday+"</td>";
                    html +=' <td><a href="javascript:delt(\''+data[i].id+'\');">删除</a></td>';
                    html +="<tr>";

                }

                $("#tdata").html(html);
            }
        });
    }
    function delt(tourist_id) {
        $.ajax({
            url:"/order/delTourist",
            type:"post",
            data:{orderid:orderid,touristid:tourist_id},
            success:function (data) {
                location.reload();
            }
        })
    }
</script>
</body>
</html>

